<%page expression_filter="h"/>
<html>
<head>
  <title>${user.firstname} ${user.lastname}'s Scrabble Players</title>
  <link rel="stylesheet" type="text/css" href="/css/default.css">
</head>
<body>
<%include file="header.tpl"/>

<%def name="checked(status)">
  % if status:
    checked
  % endif
</%def>

<%def name="enabled(is_us)">
  % if not is_us:
    disabled
  % endif
</%def>

% if not user:
  No such user.
  <% return %>
% endif

<center>
  <h1>${user.firstname} ${user.lastname}</h1>
</center>

<center>
% if len(players):
<form action="set_player_config/${user.username}" method="post">
<table>
  <tr>
      <th>Player Name</th>
      <th>Version</th>
      <th>Ranking</th>
      <th>Enabled</th>
      <th>Won</th>
      <th>Lost</th>
      <th>Tied</th>
      <th>Status Message</th>
      <th>Class Name</th>
  </tr>
% for player in players:
  <tr>
      <td><a href="/user/${user.username}/${player.name}/${player.version}">${player.name}</a></td>
      <td>${player.version}</td>
      <td>${player.rank}</td>
      <td><input type="checkbox"
                 value="${player.name}|${player.version}"
                 name = "enabled"
                 ${enabled(is_us)}
                 ${checked(player.enabled)}</td>
      <td>${player.games_won}</td>
      <td>${player.games_lost}</td>
      <td>${player.games_tied}</td>
      <td>${player.status_message}</td>
      <td>${player.player_class_name}</td>
  </tr>
% endfor
</table>
  % if is_us:
<input type="submit" value="Submit Changes">
  % endif
</form>
% else:
  % if is_us:
    You have
  % else:
  ${user.firstname} has
 % endif
  no players yet.
% endif
</center>
  

## If the user owns this page, allow them to add a player.
% if is_us:
<div style="border:1px black solid; padding: 10px;">
<center><h5>Add Player!</h5></center>
<form action="add_player" method="post" enctype="multipart/form-data">
Player Name: <input type="text" name="player_name" value="${user.firstname}"><br>
<input type="file" name="file_obj" value="Upload Player"><br>
<input type="hidden" name="username" value="${username}"><br>
<input type="submit" value="Upload">
</form>
</div>
% endif
</body>
</html>
